<%@page import="com.glowdayz.common.Util"%>
<%@page import="com.glowdayz.glowmee.dao.ProductDAO"%>
<%@page import="com.glowdayz.common.DBHandler"%>
<%@page import="java.util.ArrayList"%>
<%@ page language="java" contentType="text/xml; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ page trimDirectiveWhitespaces="true" %>
<%
	request.setCharacterEncoding("utf-8");
	String typehead = request.getParameter("typehead");
	typehead = Util.getInstance().incoding(typehead);
	String json = null;
	if (!typehead.equals("")) {
		DBHandler.getInstance().connect();
		ArrayList<String> productList = ProductDAO.getInstance().getProductTitleList(typehead);
		if (productList.size() > 0) {
			json = "[ ";
			for (int i=0; i<productList.size(); i++) {
				json += "{ name: '" + productList.get(i) + "' }, ";
			}
			json = json.substring(0, json.length() - 2) + " ]";
		}
		DBHandler.getInstance().disconnect();
	}
%>
<%= json %>